package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo15MapValues {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf()

    conf.setAppName("union")

    conf.setMaster("local")

    val sc = new SparkContext(conf)

    val idAgeRDD: RDD[(String, Int)] = sc.parallelize(List(
      ("001", 23),
      ("002", 24),
      ("003", 25),
      ("004", 23))
    )

    /**
      * mapValues: key不变，对value做处理
      *
      */
    val rdd: RDD[(String, Int)] = idAgeRDD.mapValues(age => age + 1)

    rdd.foreach(println)
  }

}
